package com.basin.micro.auth.module.perm.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.basin.micro.auth.module.perm.pojo.entity.PermEntity;
import com.basin.micro.auth.module.perm.repository.PermRepository;
import com.basin.micro.auth.module.perm.service.PermService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * @author: Sam ZHONG | sammy1997@aliyun.com
 */
@Service
@Slf4j(topic = "BASIN:ADMIN:PERM_SERVICE")
@RequiredArgsConstructor
public class PermServiceImpl implements PermService {
    private final PermRepository permRepository;

    @Override
    public List<PermEntity> getPermByCode(Collection<String> perms) {
        if (ObjectUtil.isEmpty(perms)) return new ArrayList<>();

        return permRepository.list(Wrappers.<PermEntity>lambdaQuery()
                .in(PermEntity::getPermCode, perms));
    }
}
